package com.lingying.caiwudailikehudaun.verificationUtils;


public class RandomUtils {


    //所有的字符组成的串
    public static final String allChar = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    //字符串（不包括数字）
    public static final String letterChar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    //数字
    public static final String numberChar = "0123456789";
    //定义所有小写字符
    public static final String lowercase = "abcdefghijklmnopqrstuvwxyz";
    //定义所有大写字符
    public static final String bigChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    //定义特殊符号
    public static final String symbolChar = "!@#$%^&*()_+{}/*-";


    //从1到10的int型随数
    //(最小值+Math.random()*(最大值-最小值+1))
    //Math.random 0到1直接的小数
    public static int dsad() {
        return (int) (1 + Math.random() * (10 - 1 + 1));
    }

    //biggest为最大数   理论1-biggest
    public static int sdads(int biggest) {
        int num = (int) (Math.random() * biggest + 1);
        return num;
    }

    //自定义length长度  所有的字符组成的串
    public static String getRandomString(int length) {
        //StringBuffer 和 StringBuilder 类的对象能够被多次的修改，并且不产生新的未使用对象保证性能
        //在线程安全上，StringBuilder是线程不安全的，而StringBuffer是线程安全的
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            //注意：下标为从0开始
            int number = sdads(61);
            sb.append(allChar.charAt(number));
        }
        return sb.toString();
    }

    //自定义length长度   数字
    public static String getRandomInt(int length) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = sdads(9);
            sb.append(bigChar.charAt(number));
        }
        return sb.toString();
    }

    //自定义length长度   数字
    public static String getNumberCharInt(int length) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = sdads(9);
            sb.append(numberChar.charAt(number));
        }
        return sb.toString();
    }
}
